package com.innodealing.serialization;

import com.innodealing.model.UserKafkaMessage;
import org.apache.flink.api.common.serialization.DeserializationSchema;
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper;

import java.io.IOException;

/**
 * 用户Kafka消息反序列化器
 * 
 * @author 系统生成
 * @date 2024/12/18
 */
public class UserKafkaMessageDeserializationSchema implements DeserializationSchema<UserKafkaMessage> {

    private final ObjectMapper objectMapper = new ObjectMapper();

    @Override
    public UserKafkaMessage deserialize(byte[] message) throws IOException {
        return objectMapper.readValue(message, UserKafkaMessage.class);
    }

    @Override
    public boolean isEndOfStream(UserKafkaMessage nextElement) {
        return false;
    }

    @Override
    public TypeInformation<UserKafkaMessage> getProducedType() {
        return TypeInformation.of(UserKafkaMessage.class);
    }
} 